Re: [GENERAL] Determining if "in a text set"
От | Herouth Maoz |
---|---|
Тема | Re: [GENERAL] Determining if "in a text set" |
Дата | |
Msg-id | l03110702b32503ceda99@[147.233.148.145] обсуждение исходный текст |
Ответ на | Re: [GENERAL] Determining if "in a text set" (Richi Plana <richip@mozcom.com>) |
Список | pgsql-sql |
At 20:56 +0200 on 28/03/1999, Richi Plana wrote: > > 1) I'm not sure the regex thing is ANSI SQL and would port to other SQL > systems easilly That's true. ANSI only has LIKE, but it's oh-so-limited. > 2) Isn't there a way to do [^{ws}](word)[{ws}$], where [^{ws}] means > either the start or a whitespace and [{ws}$] means either a whitespace or > EOL? Hehe... Actually, there is. This is what I came up with: SELECT * FROM {class} WHERE '{phrase}' ~ ( '(^|[[:space:]])' || ( rtrim( FieldN ) || '([[:space:]]|$)' ) ); It seems a bit complicated. The [[:space:]] combination is the set of all whitespace characters. Like perl's \s, but locale-sensitive. The combination '(^|[[:space:]])' uses the regexp alternatives syntax. This means "Either the beginning of the phrase (^) or a space character". The combination '([[:space:]]|$)' is, along the same lines, "either a space character or the end of the phrase". All the rest of the mess are concatenation operators, and the parentheses required for their precedence and associativity. > 3) When I try the concat strings operator (||), I get the following psql > error: Yes, you are right about the precedence (I don't know why I didn't encounter it yesterday). One must also remember that the || operator is also non-associative (no real reason for it - it's a minor bug), so you have to put parentheses around it if you concat more than two strings. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
В списке pgsql-sql по дате отправления: